package org.zjx.command.character;

import lombok.Getter;

@Getter
public enum Health {
    HEALTHY("健康", 0),
    CRITICAL("濒危", 1),
    DEAD("死亡", 2),
    FULL_SEAL("全封印", 3),
    PHYSICAL_SEAL("物理封印", 4),
    MAGIC_SEAL("法术封印", 5),
    SKILL_SEAL("特技封印", 6),
    POISONED("中毒", 7);

    private final String description;
    private final int code;

    Health(String description, int code) {
        this.description = description;
        this.code = code;
    }

    public static Health fromCode(int code) {
        for (Health health : values()) {
            if (health.code == code) {
                return health;
            }
        }
        throw new IllegalArgumentException("Invalid Health code: " + code);
    }

    public static Health fromDescription(String description) {
        for (Health health : values()) {
            if (health.description.equals(description)) {
                return health;
            }
        }
        throw new IllegalArgumentException("Unknown Health description: " + description);
    }

    public boolean isSealed() {
        return this == FULL_SEAL || this == PHYSICAL_SEAL || this == MAGIC_SEAL || this == SKILL_SEAL;
    }

    public boolean canAct() {
        return this == HEALTHY || this == CRITICAL || this == POISONED;
    }
}